<template>
	<view>
		<view class="cu-custom" :style="[{height:BannerBar + 'px'}]">
			<image v-if="images.length==1" class="cu-custom-img" lazy-load :style="[{height:BannerBar + 'px'}]" :src="images[0].url"></image>
			<swiper v-else class="screen-swiper" :class="[dotStyle ? 'square-dot' : 'round-dot']"
			 :indicator-dots="dots" :circular="true" :autoplay="true" interval="5000" duration="500" @change="cardSwiper"
			 indicator-color="#8799a3">

				<swiper-item v-for="(item, index) in images" :key="index" :class="cardCur == index ? 'cur' : ''">
					<block >
						<image :src="item.url" mode="aspectFill" v-if="item.type == 'image'"></image>
						<video :src="item.url" autoplay loop muted :show-play-btn="false" :controls="false" objectFit="cover" v-if="item.type == 'video'"></video>
					</block>
					
				</swiper-item>
			</swiper>
			<view class="cu-bar fixed search" :style="style" :class="[scrollTop==0?'none-bg text-white bg-img':'bg-white',bgColor]">
				<view class="action" @tap="onLeft" v-if="isBack">
					<slot name="left"></slot>
				</view>
				<view class="content" :style="[{top:StatusBar + 'px'}]">
					<slot name="content"></slot>
				</view>
				<slot name="right"></slot>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				StatusBar: this.StatusBar,
				CustomBar: this.CustomBar,
				BannerBar: this.CustomBar + 140,
				cardCur: 0,
				towerStart: 0,
				direction: ''
			};
		},
		name: 'cu-custom',
		computed: {
			style() {
				var StatusBar = this.StatusBar;
				var CustomBar = this.CustomBar;
				var bgImage = this.bgImage;
				var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
				if (this.bgImage) {
					style = `${style}background-image:url(${bgImage});`;
				}
				return style
			}
		},
		props: {
			bgColor: {
				type: String,
				default: ''
			},
			isBack: {
				type: [Boolean, String],
				default: true
			},
			bgImage: {
				type: String,
				default: ''
			},
			images: Array,
			scrollTop: {
				type: [Number, String],
				default: 0
			},
			dotStyle: {
				type: [Boolean, String],
				default: false
			},
			typeStyle: {
				type: [Boolean, String],
				default: false
			},
			dots:{
				type: [Boolean, String],
				default: false
			}

		},
		methods: {
			onLeft() {
				// this.$emit('onleft', true);
				uni.navigateBack({
					delta: 1
				});
			},
			onRight() {
				this.$emit('onright', true);
			},
			onClick() {
				this.$emit('onclick', true);
			},
			cardSwiper(e) {
				this.cardCur = e.detail.current;
			}
		}
	}
</script>

<style scoped>
	.cu-bar {
		background: no-repeat;
	}

	.action {
		margin-left: 20upx;
	}

	.cu-custom-img {
		width: 100%;

	}

	.cu-bar .content {
		font-size: 36upx;
		font-family: FZLTHK--GBK1-0;
		font-weight: 400;
		color: rgba(255, 255, 255, 1);
	}
</style>
